package com.hjqjl.whdemo.feature.feature0.ui.activity.list.recyclerview;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.hjqjl.whdemo.R;
import com.hjqjl.whdemo.base.BaseActivity;
import com.hjqjl.whdemo.databinding.ActivityMultipleListBinding;
import com.hjqjl.whdemo.feature.feature0.ui.activity.list.recyclerview.model.MultipleItemModel;

import java.util.ArrayList;
import java.util.List;

public class MultipleItemListActivity extends BaseActivity {
    public static void start(Context context) {
        Intent starter = new Intent(context, MultipleItemListActivity.class);
        context.startActivity(starter);
    }

    private final List<MultipleItemModel> mMultipleItemModelList = new ArrayList<>();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityMultipleListBinding binding = ActivityMultipleListBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());

        initMultipleItemModels();
        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        binding.homeRvMultipleItemList.setLayoutManager(layoutManager);
        MultipleItemAdapter adapter = new MultipleItemAdapter(mMultipleItemModelList);
        binding.homeRvMultipleItemList.setAdapter(adapter);
    }

    /**
     * 初始化模拟数据
     */
    private void initMultipleItemModels() {
        mMultipleItemModelList.add(new MultipleItemModel(0, "我是个标题，是recycleview多布局中的一个布局", 0));
        for (int i = 0; i < 2; i++) {
            MultipleItemModel apple = new MultipleItemModel(1, "Apple", R.drawable.ic_image_default);
            mMultipleItemModelList.add(apple);
            MultipleItemModel banana = new MultipleItemModel(1, "Banana", R.drawable.ic_image_default);
            mMultipleItemModelList.add(banana);
            MultipleItemModel orange = new MultipleItemModel(1, "Orange", R.drawable.ic_image_default);
            mMultipleItemModelList.add(orange);
            MultipleItemModel watermelon = new MultipleItemModel(1, "Watermelon", R.drawable.ic_image_default);
            mMultipleItemModelList.add(watermelon);
            MultipleItemModel pear = new MultipleItemModel(1, "Pear", R.drawable.ic_image_default);
            mMultipleItemModelList.add(pear);
            MultipleItemModel grape = new MultipleItemModel(1, "Grape", R.drawable.ic_image_default);
            mMultipleItemModelList.add(grape);
            MultipleItemModel pineapple = new MultipleItemModel(1, "Pineapple", R.drawable.ic_image_default);
            mMultipleItemModelList.add(pineapple);
            MultipleItemModel strawberry = new MultipleItemModel(1, "Strawberry", R.drawable.ic_image_default);
            mMultipleItemModelList.add(strawberry);
            MultipleItemModel cherry = new MultipleItemModel(1, "Cherry", R.drawable.ic_image_default);
            mMultipleItemModelList.add(cherry);
            MultipleItemModel mango = new MultipleItemModel(1, "Mango", R.drawable.ic_image_default);
            mMultipleItemModelList.add(mango);
        }
    }
}
